<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<% 
	String path = request.getContextPath();
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<c:set var="path" value="${pageContext.request.contextPath}"></c:set>
<script type="text/javascript" src="${path }/js/jquery-3.6.0.min.js"></script>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>修改密码</title>

<link rel="icon" type="image/png"
	href="<%= path %>/assets/images/favicon-32x32.png">

<link rel="stylesheet" href="<%= path %>/assets/main/css/fonts.css">
<link rel="stylesheet" href="<%= path %>/assets/main/css/style.css">
</head>

<body>

	<div id="main-wrapper" class="show">


		<!-- start logo components -->
		<div class="nav-header">
			<div class="brand-logo">
				<a href="index.html"><img class="brand-title"
					src="<%= path %>/assets/images/logo.png" alt=""></a>
			</div>
		</div>

		<aside class="left-panel nicescroll-box">


			<nav class="navigation">
				<ul class="list-unstyled main-menu">
					<li class="has-submenu"><a
						href="${path }/MyCollectionController?action=getMyCollection">
							<i class="fas fa-th-large"></i> <span class="nav-label">我的收藏</span>
					</a></li>
					<li class="has-submenu"><a
						href="${path }/PostController?action=show"> <i
							class="fas fa-calendar-plus"></i> <span class="nav-label">我的发布</span>
					</a></li>
					<li class="has-submenu"><a
						href="${path }/UpdatePasswordController?action=changeuserpass">
							<i class="fas fa-chart-pie"></i> <span class="nav-label">修改密码</span>
					</a></li>
					<li class="has-submenu"><a
						href="${path}/UpdateUserinfoCenterController?action=UpdateUserinfoCenterById">
							<i class="fas fa-cog"></i> 修改个人信息
					</a></li>
					<li class="has-submenu"><a
						href="${path}/PostNumberLikesController?action=postNumberLikes">
							<i class="fas fa-cog"></i> 获赞
					</a></li>
					<li class="has-submenu"><a
						href="${path}/CommentReplyController?action=findAll"> <i
							class="fas fa-cog"></i> 我的帖子
					</a></li>
				</ul>
			</nav>

			<div class="sidebar-widgets">
				<div class="top-sidebar box-shadow mx-25 m-b-30 p-b-20 text-center">
					<img src="<%= path %>/assets/images/appointement.svg"
						class="side-img" alt="img">
				</div>
				<div class="copyright text-center">
					<p class="mb-0">中国航天</p>
					<p class="mb-0">© 2021</p>
				</div>
			</div>
		</aside>



		<jsp:include page="/inc/signter.jsp"></jsp:include>


		<div class="content-body">
			<div class="warper container-fluid">
				<div class="add_Test main_container">
					<div class="row page-titles mx-0">
						<div class="col-sm-6 p-md-0">
							<div class="welcome-text">
								<h4 class="text-primary">修改密码</h4>
								<p class="mb-0">Update Password</p>
							</div>
						</div>

					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
						<div class="card shadow mb-4">
							<div class="card-header">
								<h4 class="card-title">编辑密码</h4>
							</div>
			
							<div class="card-body">
								<div class="basic-form">
									<form id="usForm"
										action="${path }/UpdatePasswordController?action=updateUserinfoPassword"
										method="post">
										<div class="row">
											<div class="col-xl-12">
												<div class="form-group">
													<span>原密码</span> <input id="primaryPassword"
														name="primaryPassword" type="text" class="form-control"
														placeholder="请输入原密码" /> <span id="primaryPasswordMsg"></span>
												</div>
											</div>
											<div class="col-xl-12">
												<div class="form-group">
													<span>新密码</span> <input id="password" name="password"
														type="text" class="form-control"
														placeholder="新密码的长度不得少于六位" /> <span id="passwordMsg"></span>
												</div>
											</div>
											<div class="col-xl-12">
												<div class="form-group">
													<span>确认密码</span> <input id="confirmPassword" type="text"
														class="form-control" placeholder="确认密码和新密码保持一致" /> <span
														id="confirmPasswordMsg"></span>
												</div>
											</div>
											<div class="col-xl-12">
												<div class="form-group">

													<input type="button" value="保存"
														id="subBtn" />
												</div>
											</div>
										</div>
									</form>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

		<div class="footer">
			<div class="copyright">
				<p class="mb-0">Copyright ©&中国航天 &amp;2021
			</div>
		</div>

	</div>

	<script src="<%= path %>/js/jquery-3.6.0.min.js"></script>

	<script src="<%= path %>/assets/plugins/popper/popper.min.js"></script>

	<script src="<%= path %>/assets/plugins/bootstrap/js/bootstrap.min.js"></script>

	<script src="<%= path %>/assets/plugins/moment/moment.min.js"></script>

	<script
		src="<%= path %>/assets/plugins/daterangepicker/daterangepicker.min.js"></script>

	<script
		src="<%= path %>/assets/plugins/datatables/jquery.dataTables.min.js"></script>
	<script src="<%= path %>/assets/js/init-tdatatable.js"></script>

	<script
		src="<%= path %>/assets/plugins/chart/apexcharts-bundle/js/apexcharts.min.js"></script>
	<script src="<%= path %>/assets/js/apex-custom.js"></script>

	<script src="<%= path %>/assets/js/toggleFullScreen.js"></script>
	<script src="<%= path %>/assets/js/main.js"></script>

</body>

</html>

<%--修改密码验证 --%>
<script type="text/javascript">
$(function(){
	
	//原密码提示验证
    $("#primaryPassword").bind("input proprechange",function(){
    	//原密码
		   var primaryPassword=$("#primaryPassword").val();
		   if(!primaryPassword){
			   $("#primaryPasswordMsg").html("原密码不能为空");
			   $("#primaryPasswordMsg").css("color","blue");
		   }else{
			   $("#primaryPasswordMsg").empty();
		   }  
    })
   
   //新密码提示验证
    $("#password").bind("input proprechange",function(){
    	 var password=$("#password").val();
		   if(password.length<6){
			   $("#passwordMsg").html("新密码的长度不得少于六位");
			   $("#passwordMsg").css("color","blue");
		   }else{
			   $("#passwordMsg").empty();
		   }
    })
    //确认密码提示验证
    $("#confirmPassword").bind("input proprechange",function(){
			   var password=$("#password").val();
		   var confirmPassword=$("#confirmPassword").val();
		   if(confirmPassword!=password){
			   $("#confirmPasswordMsg").html("确认密码和新密码保持一致");
			   $("#confirmPasswordMsg").css("color","blue");
		   }else{
			   $("#confirmPasswordMsg").empty();
		   }
    })
	
  
	
	   //修改密码保存按钮的点击事件
	   $("#subBtn").click(function(){
		  //用户没有登录
		   if(${empty(sessionScope.userinfo)}){ 
			   alert("请登录");
		   }else{
			   var pass=confirm("您确认要修改密码吗?");
			   if(pass==true){
				 //原密码
				   var primaryPassword=$("#primaryPassword").val();
				 
				   if(!primaryPassword){
					   $("#primaryPasswordMsg").html("原密码不能为空");
					   $("#primaryPasswordMsg").css("color","red");
					   $("#primaryPassword").select();
					   return;
				   }else{
					   $("#primaryPasswordMsg").empty();
				   } 
				  
				   
				 //新密码
				   var password=$("#password").val();
				   if(password.length<6){
					   $("#passwordMsg").html("新密码的长度不得少于六位");
					   $("#passwordMsg").css("color","red");
					   $("#password").select();
					   return;
				   }else{
					   $("#passwordMsg").empty();
				   }
				   
				   //确认密码
				   var confirmPassword=$("#confirmPassword").val();
				   if(confirmPassword!=password){
					   $("#confirmPasswordMsg").html("确认密码和新密码保持一致");
					   $("#confirmPasswordMsg").css("color","red");
					   $("#confirmPassword").select();
					   return;
				   }else{
					   $("#confirmPasswordMsg").empty();
				   }
				   //提交form表单
				   $("#usForm").submit();
			   }
		   }
		  
		   
	   })
})

</script>




<script type="text/javascript">
$(function(){
	
		$("#primaryPassword").blur(function(){
			
			var pass = $("#primaryPassword").val();
			$.get("${path}/UpdatePasswordController?action=passwordAjax&pass="+pass,function(mes){
			if(mes=="no"){
				$("#primaryPasswordMsg").html("原密码错误");
				   $("#primaryPasswordMsg").css("color","red");
				   $("#primaryPassword").select();
				   return;
			}else{
				$("#primaryPasswordMsg").empty();
			}
		  })
		})
	

})  
</script> 





